package com.slkj.shilixiaoyuanapp.ui.teacher.tool.notice;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.base.BaseLazyFragment;
import com.slkj.shilixiaoyuanapp.entity.NoticeDetailEntity;
import com.slkj.shilixiaoyuanapp.entity.ToolWorkListEntity;
import com.slkj.shilixiaoyuanapp.util.ListUtils;
import com.slkj.shilixiaoyuanapp.view.DividerItemDecoration;
import com.slkj.shilixiaoyuanapp.view.StateLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created  on 2018-07-20
 *
 * @author 唐开阔
 * @describe 未交
 */
public class NoticeDetailUnReadFragment extends BaseLazyFragment{
    @BindView(R.id.recycer)
    RecyclerView recycerType;
    BaseQuickAdapter adapter;
    @BindView(R.id.statelayout)
    StateLayout stateLayout;
    List<ToolWorkListEntity> toolWorkListEntityList =new ArrayList<>();
    public ArrayList<NoticeDetailEntity.ReadEntity> unRead;
    public static NoticeDetailUnReadFragment get(ArrayList<NoticeDetailEntity.ReadEntity> unRead){
        NoticeDetailUnReadFragment noticeDetailReadFragment = new NoticeDetailUnReadFragment();
        noticeDetailReadFragment.unRead = unRead;
        return noticeDetailReadFragment;
    }
    @Override
    protected int getResId() {
        return R.layout.fragment_tool_work_detail_upload;
    }

    @Override
    protected void onRealLoaded() {
        for (int i = 0; i < 20; i++) {
            toolWorkListEntityList.add(new ToolWorkListEntity()) ;
        }
        recycerType.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
        recycerType.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new BaseQuickAdapter<NoticeDetailEntity.ReadEntity, BaseViewHolder>(R.layout.item_tool_notice_read_detail, unRead) {
            @Override
            protected void convert(BaseViewHolder helper, final NoticeDetailEntity.ReadEntity item) {
                Glide.with(getContext()).load(item.getHead()).error(R.drawable.ic_man).into((ImageView) helper.getView(R.id.tv_level));
                helper.setText(R.id.tv_name,item.getName())
                        .setText(R.id.tv_info,item.getClassName());
                Log.d(TAG, ">>>convert---" + item.toString());
            }
        };
        recycerType.setAdapter(adapter);
        if (ListUtils.isEmpty(unRead)){
            stateLayout.showEmptyView();
        }
    }
}
